package com_2;

import java.util.Comparator;
import java.util.TreeSet;

public class StudentDemo {
    public static void main(String[] args) {
        TreeSet<Student> t = new TreeSet<Student>(new Comparator<Student>() {
            @Override
            public int compare(Student s1, Student s2) {
                int num = s1.getAge() - s2.getAge();
                int num2 = num == 0 ? s1.getName().compareTo(s2.getName()) : num;
                return num2;
            }
        });
      Student s3=new Student("小工",18);
        Student s4=new Student("小红",19);
        Student s5=new Student("小白",17);
        t.add(s3);
        t.add(s4);
        t.add(s5);
        for (Student s6 : t) {
            System.out.println(s6.getName()+s6.getAge());

        }


    }
}
